package com.dawn.interestmanage.serviceimpl;

import com.dawn.interestmanage.bean.InterestinfoBean;
import com.dawn.interestmanage.dao.InterestinfoDao;
import com.dawn.interestmanage.service.InterestinfoService;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InterestinfoServiceImpl implements InterestinfoService {

	private static Logger logger = Logger
			.getLogger(InterestinfoServiceImpl.class);

	@Autowired
	private InterestinfoDao interestinfoDao;

	public InterestinfoBean findInterByIid(int interestId) {
		// TODO Auto-generated method stub
		List<InterestinfoBean> interests = interestinfoDao
				.findInterByIid(interestId);
		if (!interests.isEmpty()) {
			InterestinfoBean interest = interests.get(0);
			return interest;
		}
		return null;
	}

	public InterestinfoBean findInterByIName(String interestName) {
		// TODO Auto-generated method stub
		List<InterestinfoBean> interests = interestinfoDao
				.findInterByIName(interestName);
		if (!interests.isEmpty()) {
			InterestinfoBean interest = interests.get(0);
			return interest;
		}
		return null;
	}

	public List<InterestinfoBean> findAllInter() {
		List<InterestinfoBean> interests = interestinfoDao.findAllInter();
		if (!interests.isEmpty()) {
			return interests;
		}
		return null;
	}

	public int AddInterest(InterestinfoBean ib) {
		interestinfoDao.addInterest(ib);
		return 1;

	}

	public int DelInterest(InterestinfoBean ib) {
		interestinfoDao.delInterest(ib);
		return 1;

	}

}
